package com.yihu.cms.service;

import java.io.IOException;

import com.yihu.article.beans.ArticleContent;
import com.yihu.article.beans.EditorManagerPage;
import com.yihu.dataService.hessian.mongodb.interfaceService.ArticleHService;
import com.yihu.dataService.hessian.resource.ResourceMongoDBManager;


public class ArticleService{
	ArticleHService articleService = null;
	public ArticleService(){
		try {
			articleService= (ArticleHService)ResourceMongoDBManager
					.getSingleton().getBeans("articleHSC");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public int add(String articleJson) {
		// TODO Auto-generated method stub
		System.err.println("addArticle");
		int result = 0;
		result = articleService.addArticle(articleJson);
		return result;
	}

	public int delete(String id) {
		// TODO Auto-generated method stub
		return articleService.deleteArticle(id);
	}

	public String getArticleById(String id) {
		String result = "";
		result = articleService.getArticleById(id);
		return result;
	}

	public int update(String articleJson) {
		int result = 0;
		result = articleService.updateArtileByid(articleJson);
		
		return result;
	}
	
	public Object auditAticle(String articleId) {
		
		return articleService.auditAticle(articleId);
	}

	public String getArticlesPaging(String queryJson) {
		// TODO Auto-generated method stub
		String json = articleService.getArticlesPaging(queryJson);
		return json;
	}
	
	public String getUsersPaging(String queryJson) {
		// TODO Auto-generated method stub
		String json = articleService.getArticlesPaging(queryJson);
		System.out.println("cms.json: "+json);
		return json;
	}
	
	public int uploadFile(String fileJson){
		return articleService.uploadFile(fileJson);
	}
	
	public int autoSave(String contentJson){
		return articleService.autoSave(contentJson);
	} 

	public ArticleContent getAutoCotent(String contentJson){
		return articleService.getAutoCotent(contentJson);
	} 

	public EditorManagerPage getAttachmentsPaging(String queryJson){
		// TODO Auto-generated method stub
		EditorManagerPage page = articleService.getAttachmentsPaging(queryJson);
		return page;
	}
	
	public int deleteAttachment(String ids) {
		// TODO Auto-generated method stub
		return articleService.deleteAttachment(ids);
	}
}
